﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Gronia.WPF.Classes
{
    public static class MathUtilities
    {
        public static int Clamp(int value, int min, int max)
        {
            if (value < min) return min;
            if (value > max) return max;
            return value;
        }

        public static double Clamp(double value, double min, double max)
        {
            if (value < min) return min;
            if (value > max) return max;
            return value;
        }

        public static int Clamp(int value, int degree)
        {
            while (value < 0) { value += degree; }
            while (value >= degree) { value -= degree; }
            return value;
        }

        public static double Clamp(double value, double degree)
        {
            while (value < 0) { value += degree; }
            while (value >= degree) { value -= degree; }
            return value;
        }
    }
}